package com.flyduck.vueshop.order.remote.controller;

import com.flyduck.vueshop.common.core.lang.Result;
import com.flyduck.vueshop.common.sotoken.annotation.InnerAuth;
import com.flyduck.vueshop.order.remote.service.RemoteOrderItemService;
import com.flyduck.vueshop.order.remote.service.RemoteOrderService;
import com.flyduck.vueshop.order.vo.RemoteOrderItemRespVO;
import com.flyduck.vueshop.order.vo.RemoteOrderItemUpdateReqVO;
import com.flyduck.vueshop.order.vo.RemoteOrderRespVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * RemoteOrderController
 * </p>
 *
 * @author flyduck
 * @since 2024-07-23
 */
@RestController
@RequestMapping("/order/remote/order")
public class RemoteOrderItemController {

    @Resource
    private RemoteOrderItemService remoteOrderItemService;

    @InnerAuth
    @GetMapping("/getOrderItemById/{id}")
    public Result<RemoteOrderItemRespVO> getOrderItemById(@PathVariable("id") Long id){
        RemoteOrderItemRespVO remoteOrderItemRespVO = remoteOrderItemService.getOrderItemById(id);
        return Result.success(remoteOrderItemRespVO);
    }

    @InnerAuth
    @GetMapping("/updateOrderItem")
    Result<Void> updateOrderItem(@RequestBody RemoteOrderItemUpdateReqVO remoteOrderItemUpdateReqVO){
        remoteOrderItemService.updateOrderItem(remoteOrderItemUpdateReqVO);
        return Result.success();
    }

}
